-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(plugin-vercel-analytics): add new vercel analytics plugin #9687
Conversation
⚡️ Lighthouse report for the deploy preview of this PR
|
✅ [V2]
To edit notification comments on pull requests, go to your Netlify site configuration. |
TODO: add documentation | ||
|
||
See [plugin-vercel-analytics documentation](). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need plugin docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed before merge:
- little refactors, see inline comments
- docs
- options validation + unit tests
- forbid usage of pluginId !== "default" with clear error message
packages/docusaurus-plugin-vercel-analytics/src/plugin-vercel-analytics.d.ts
Outdated
Show resolved
Hide resolved
d9d6e3d
to
b243a96
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That almost looks good to merge
export type Options = Partial<PluginOptions>; | ||
|
||
export const DEFAULT_OPTIONS: Partial<PluginOptions> = { | ||
mode: 'production', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think undefined
("auto") makes more sense as a default
For example docusaurus build --dev
builds the site with node env "development" and we probably want it to impact the vercel plugin env in that case.
See also:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what you mean with undefined
("auto") but I changed the default value to auto which makes more sense
|
||
export const DEFAULT_OPTIONS: Partial<PluginOptions> = { | ||
mode: 'production', | ||
debug: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also use undefined
?
https://vercel.com/docs/analytics/package#debug
This option is automatically enabled if the NODE_ENV environment variable is available and either development or test.
Similarly I think using docusaurus build --dev
should turn this plugin to debug mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, didn't understand the use of undefined
however modified according to your comment
Motivation
This plugin adds support for Vercel Web Analytics.
You should only use this plugin if you use Vercel to host Docusaurus (which is a good option).
You are only supposed to use this plugin at most once per Docusaurus site, so it is not allowed to use multiple instances of this plugin. We reject the usage of a custom plugin id.
Plugin documentation: https://deploy-preview-9687--docusaurus-2.netlify.app/docs/api/plugins/@docusaurus/plugin-vercel-analytics/
This plugin only exposes the
mode
anddebug
options.Building your site with
docusaurus build --dev
will turn on development env and debug mode automatically.Other options are not supported for now, but we'll consider adding support for them.
beforeSend()
track
Please let us know if you need them and we'll try to add support later.
Test Plan
Unit tests
The Docusaurus website does not use Vercel, so we cannot dogfood this on our own website.
However, maintainer @slorber uses it on his newsletter website ThisWeekInReact.com and it works fine:
Test links
https://deploy-preview-9687--docusaurus-2.netlify.app/
Related issues/PRs